package com.yuanheng100.ems4j.service;

import net.sf.ehcache.CacheManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 启动服务类
 * <p/>
 * Created by wangguangshuo on 2016/12/14.
 */
public class ServiceLauncher
{

    private static final Logger log = LoggerFactory.getLogger(ServiceLauncher.class);

    private static ClassPathXmlApplicationContext ctx_producer = null;

    public void start()
    {
        log.info("ServiceLauncher starting.");
        ctx_producer = new ClassPathXmlApplicationContext(new String[]{"spring/applicationContext.xml"});
        ctx_producer.start();
        log.info("ServiceLauncher started.");
    }

    public void stop()
    {
        log.info("ServiceLauncher stopping.");
        CacheManager.getInstance().shutdown();
        ctx_producer.stop();
        ctx_producer.destroy();
        log.info("ServiceLauncher stoped.");
    }

}
